import request from '@/utils/request'
import { parseStrEmpty } from "@/utils/ruoyi";

// 查询用户分页列表
export function getUserPageList(query) {
  return request({
    url: '/system/userManage/page',
    method: 'get',
    params: query
  })
}

// 查询用户详细
export function getUser(userId) {
  return request({
    url: '/system/userManage/getUser/' + parseStrEmpty(userId),
    method: 'get'
  })
}

// 新增用户
export function addUser(data) {
  return request({
    url: '/system/userManage/add',
    method: 'post',
    data: data
  })
}

// 修改用户
export function updateUser(data) {
  return request({
    url: '/system/userManage/update',
    method: 'put',
    data: data
  })
}

// 删除用户
export function delUser(userId) {
  return request({
    url: '/system/userManage/delete/' + userId,
    method: 'delete'
  })
}

// 用户密码重置
export function resetUserPwd(userId) {
  return request({
    url: '/system/userManage/resetPwd/' + parseStrEmpty(userId),
    method: 'put'
  })
}

// 个人中心--查询用户个人信息
export function getUserProfile() {
  return request({
    url: '/user/profile/getUserProfile',
    method: 'get'
  })
}

// 修改用户个人信息
export function updateUserProfile(data) {
  return request({
    url: '/user/profile/updateUserProfile',
    method: 'put',
    data: data
  })
}

// 用户密码重置
export function updateUserPwd(oldPassword, newPassword, sureNewPassword) {
  const data = {
    oldPassword: oldPassword,
    newPassword: newPassword,
    sureNewPassword: sureNewPassword
  }
  return request({
    url: '/user/profile/updatePassword',
    method: 'put',
    data: data
  })
}
